package com.xiaocg.base.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

class Thread1 implements Callable{
    @Override
    public Integer call() throws Exception {
        return 20;
    }
}

/**
 * @author xiaocg
 */
public class FutureTaskDemo {
    public static void main(String[] args)throws Exception {
        FutureTask futureTask = new FutureTask(new Thread1());
        Thread aa = new Thread(futureTask, "aa");
        aa.start();
        while (!futureTask.isDone()){
            System.out.println("waiting....");
        }
        System.out.println("返回值:" + futureTask.get());
    }
}
